package com.kwin.demo.server.controller;

import com.alibaba.fastjson.JSON;
import com.kwin.demo.api.dto.req.TestReq;
import com.kwin.demo.server.framework.common.repeatsubmit.annotation.RepeatSubmit;
import org.springframework.web.bind.annotation.*;

/**
 * @author kwin
 * @Date 2022/1/16 18:36
 **/
@RestController
public class TestController {

    @GetMapping("/test/{random}")
    @RepeatSubmit(location = "test", timeout = 10)
    public String test(@PathVariable("random") String random) throws InterruptedException {
//        Thread.sleep(10000);

        Thread.sleep(9000);
        return random;
    }

    @PostMapping("/test2")
    @RepeatSubmit(location = "test2", timeout = 10, argName = "random")
    public String test2(@RequestBody TestReq req) throws InterruptedException {
        Thread.sleep(5000);
        return JSON.toJSONString(req);
    }

}
